package junit;

import java.util.Calendar;
import java.util.Date;
import java.util.List;

import org.junit.Assert;
import org.junit.Test;

public class TestDatabase extends Assert {

	@Test
	public void TestHolidays() {

		List<Date> holidays = TestHelper.getAppDataAccess().getNyseHolidays();

		int futureHolidayCt = 0;

		Date now = new Date();
		for (Date d : holidays) {
			
			System.out.println(d);
			
			if (now.before(d))
				futureHolidayCt++;

			// Make sure none of the nyse holidays are on a weekend
			// This probably results in the dates being entered
			// incorrectly into the DB
			Calendar c = Calendar.getInstance();
			c.setTime(d);
			assertFalse(c.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY
					|| c.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY);

		}

		// make sure the holiday table is still populated with plenty
		// of future dates
		assertTrue(futureHolidayCt >= 8);
	}
}
